<?php
namespace Member\Model;
use Think\Model;
class DownloadModel extends Model
{
	protected $_auto = array(
			array('dateline', NOW_TIME, self::MODEL_BOTH, 'string'),
			array('ip', 'get_client_ip', self::MODEL_INSERT, 'function'),
	);	
	
	public function update($data, $iscreate = TRUE) {
		if ($iscreate == TRUE) {
			$data = $this->create($data);
		}
		if (empty($data)) {
			$this->error = $this->getError();
			return false;
		}
		if (isset($data['downloadid']) && is_numeric($data['downloadid'])) {
			$result = $this->save($data);
			if (!$result) {
				$this->error = '更新数据失败';
				return false;
			}
		} else {
			$result = $this->add($data);
			if ($result === false) {
				$this->error = '新增数据失败';
				return false;
			}
		}
		return $result;
	}
	
	
}